<!-- Faraday Penetration Test IDE -->
<!-- Copyright (C) 2013  Infobyte LLC (http://www.infobytesec.com/) -->
<!-- See the file 'doc/LICENSE' for the license information -->

<form name="form" novalidate>
    <div class="modal-header">
        <div class="modal-button btn-toolbar">
            <button class="btn btn-success" ng-click="ok()" ng-disabled="form.$invalid || (data.name == '') || (data.exploitation === '')">OK</button>
            <button class="btn btn-danger" ng-click="cancel()">Cancel</button>
        </div>
        <h3 class="modal-title">New Vulnerability Template</h3>
    </div>
    <div class="modal-body">
        <div class="mt-3">

            <!-- Nav tabs -->
            <ul class="nav nav-tabs" id="nav-tabs-container">
                <li class="nav-item active" ng-class="{'has-error': formEdit.desc.$invalid}">
                        <a class="nav-link active" data-toggle="tab" data-target="#general"
                           href="javascript:;">General</a>
                    </li>
                <li class="nav-item">
                    <a class="nav-link" data-toggle="tab" data-target="#custom_fields" href="javascript:;">Custom FIelds</a>
                </li>
            </ul>

            <!-- Tab panes -->
            <div class="tab-content height-100 ">
                <div id="general" class="container tab-pane-container tab-pane active visible-overflow"><br>
                    <div class="col-md-12 margin-bottom-15px">
                        <div class="form-horizontal">
                            <div class="form-group">
                                <div class="col-md-6">
                                    <label for="model">Name *</label>
                                    <input type="text" name="name" class="form-control" placeholder="Name" ng-model="data.name" required>
                                </div><!-- .col-md-6 -->
                                <div class="col-md-12">
                                    <p class="has-error" ng-show="(form.name.$touched && form.name.$error.required)">
                                        <span class="help-block">Vulnerability Template name is required</span>
                                    </p>
                                </div><!-- .col-md-12 -->
                            </div><!-- .form-group -->
                            <div class="form-group">
                                <div class="col-md-12">
                                    <label for="description">Description</label>
                                    <textarea class="form-control" name="description" placeholder="Description" ng-model="data.description"></textarea>
                                </div>
                            </div><!-- .form-group -->
                            <div class="form-group">
                                <div class="col-md-12">
                                    <label for="data">Data</label>
                                    <textarea class="form-control" id="data" placeholder="Data" ng-model="data.data"></textarea>
                                </div>
                            </div><!-- .form-group -->
                            <div class="form-group">
                                <div class="col-md-12">
                                    <label for="resolution">Resolution</label>
                                    <textarea class="form-control" name="resolution" placeholder="Resolution" ng-model="data.resolution"></textarea>
                                </div>
                            </div><!-- .form-group -->

                            <div class="form-group">
                                <div class="col-md-12">
                                    <label for="references">References</label>
                                    <div class="input-group margin-bottom-sm">
                                        <label class="sr-only" for="references">References</label>
                                        <input type="text" class="form-control" id="references" placeholder="References" ng-model="new_reference"/>
                                        <span class="input-group-addon cursor" ng-click="newReference()"><i class="fa fa-plus-circle"></i></span>
                                    </div>
                                </div>
                                <div class="col-md-12 reference" ng-repeat="reference in data.references">
                                    <div class="input-group margin-bottom-sm">
                                        <label class="sr-only" for="ireferences">References</label>
                                        <input type="text" class="form-control" id="ireferences" placeholder="References" ng-model="reference" readonly/>
                                        <span class="input-group-addon cursor" ng-click="data.references.splice($index, 1)"><i class="fa fa-minus-circle"></i></span>
                                    </div>
                                </div>
                            </div><!-- .form-group -->


                            <div class="form-group">
                                <div class="col-md-12">
                                    <label for="vuln-policyviolations">Policy Violations</label>
                                    <div class="input-group margin-bottom-sm">
                                        <label class="sr-only" for="vuln-policyviolations">Policy Violations</label>
                                        <input type="text" class="form-control" id="vuln-policyviolations" placeholder="Policy Violations" ng-model="new_policyviolation"/>
                                        <span class="input-group-addon cursor" ng-click="newPolicyViolation()"><i class="fa fa-plus-circle"></i></span>
                                    </div>
                                </div>
                                <div class="col-md-12 reference" ng-repeat="policyviolation in data.policyviolations">
                                    <div class="input-group margin-bottom-sm">
                                        <label class="sr-only" for="vuln-policyviolations">Policy Violation</label>
                                        <input type="text" class="form-control" id="vuln-policyviolations" placeholder="Policy Violation" ng-model="policyviolation" readonly/>
                                        <span class="input-group-addon cursor" ng-click="data.policyviolations.splice($index, 1)"><i class="fa fa-minus-circle"></i></span>
                                    </div>
                                </div>
                            </div><!-- .form-group -->

                            <div class="form-group">
                                <div class="col-md-8">
                                    <label>Impact</label>
                                    <h4><span ng-repeat="(key, value) in data.impact" class="normal-size" style="cursor: pointer;">
                                    <span ng-class="{'label-impact label-default-impact': !value, 'label-impact label-success-impact': value}" ng-click="toggleImpact(key)">{{key}}</span>
                                    </span></h4><!-- .normal-size -->
                                </div>
                                <div class="col-md-4">
                                    <label>Ease of Resolution</label>
                                    <select class="form-control" ng-model="data.easeofresolution" ng-options="e for e in easeofresolution"  style="padding:0px 12px;">
                                        <option value=""></option>
                                    </select>
                                </div>
                            </div><!-- .form-group -->

                            <div class="form-group">
                                <div class="col-md-12">
                                    <label for="Explotation">Severity *</label>
                                    <button type="button" class="btn btn-default dropdown-toggle" name="exploitation" data-toggle="dropdown"
                                            title="Choose exploitation" ng-class="{'button-error': modal.data.exploitation === undefined}">
                                    {{data.exploitation || 'Choose Severity'}} <span class="caret"></span>
                                    </button>
                                    <ul id="nav" class="dropdown-menu dropdown-menu-left" role="menu">
                                        <li ng-repeat="s in exploitations"><a href="" class="ws color-{{s}}" ng-click="data.exploitation=s">{{s}}</a></li>
                                    </ul><!-- WS navigation -->
                                </div><!-- .col-md-12 -->
                                <div class="col-md-12">
                                    <p class="has-error" ng-show="(form.exploitation.$touched && form.exploitation.$error.required)">
                                        <span class="help-block">Vulnerability Template Severity is required</span>
                                    </p>
                                </div><!-- .col-md-12 -->
                            </div>
                            <p>All fields marked * are required</p>
                        </div>
                    </div>
                </div>
                <div id="custom_fields" class="container tab-pane-container tab-pane fade"><br>
                    <div ng-if="customFields.length === 0" class="no-info-overlay" style="margin-bottom: 15px;">
                           <p class="no-info-text">
                               No custom fields were found. To create one refer to our
                               <a href="https://github.com/infobyte/faraday/wiki/Custom-Fields" target="_blank">wiki page</a>.
                           </p>
                    </div>
                    <div class="col-md-12 margin-bottom-15px">
                        <div class="col-md-12" ng-repeat="cf in customFields | orderBy : 'field_order'">
                            <!--<custom-field field="{{cf}}"></custom-field>-->
                            <div class="col-md-6">
                                <label for="model">{{cf.field_display_name}}</label>
                                <input type="text" name="name" class="form-control" placeholder="Name" ng-model="cf.value" required>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div><!-- .form-horizontal -->
    </div><!-- .modal-body -->
    <div class="modal-footer">
        <div class="modal-button btn-toolbar">
            <button class="btn btn-success" ng-disabled="form.$invalid || (data.name == '') || (data.exploitation === '')" ng-click="ok()">OK</button>
            <button class="btn btn-danger" ng-click="cancel()">Cancel</button>
        </div>
    </div>
</form>
